package com.cauli.account.menu.controller;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.convert.Convert;
import com.cauli.account.menu.model.vo.MenuVO;
import com.cauli.account.menu.service.MenuService;
import com.cauli.utils.util.ResultResponse;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Cauli
 * @date 2022/12/28 14:18
 * @description 菜单 前端控制器
 */
@Api(tags = "菜单")
@ApiSort(2)
@RestController
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    private MenuService menuService;

    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "获取用户权限标识符")
    @GetMapping( "/getPermissionList")
    public ResultResponse<List<MenuVO>> getPermissionList() {
        long userId = StpUtil.getLoginIdAsLong();
        List<MenuVO> permissionList = menuService.getPermissionList(Convert.toLong(userId), null);
        return ResultResponse.success().data(permissionList);
    }
}
